﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;

namespace DARE
{
    [AttrTypeDependentSerializable(typeof(CAnimationComponentData))]
    public class CAnimationComponent: CComponent
    {
        #region fields

        private DARE.CAnimConfig m_animConfig;

        #endregion

        #region properties

        [ContentSerializerIgnore]
        public CAnimConfig AnimConfig
        {
            get { return m_animConfig; }
            set { m_animConfig = value; }
        }

        #endregion

        #region ctor
        #endregion

        #region methods

        public override CComponent Clone(CGameObject gameObject)
        {
            CAnimationComponent anim = new CAnimationComponent();
            anim.GameObject = gameObject;
            //ajouter le clone et faire anim.m_animConfig = m_animConfig.Clone();
            anim.m_animConfig = m_animConfig;
            return anim;
        }

        public void Play(string name)
        {
            if (m_gameObject.Node != null && m_gameObject.Node.Entity.Model != null && m_gameObject.Node.Entity.Model is DARE.CModel)
                m_animConfig = (m_gameObject.Node.Entity.Model as DARE.CModel).Play(name, EAnimState.RUN | EAnimState.LOOP);
        }

        #endregion
    }
}
